﻿KISSY.ready(function (S) {
    S.use("overlay, fgt/ui", function (S, Overlay, UI) {
        var self = this,
                All = S.all,
                J = jQuery,
                resultCode = FGT.core.constant.jsonResultCode,
                userPopup,
                userPopupNode = All("#user_popup"),
                userPopupShow = All("#J_ShowUserPopup"),
                navLoggedOut = All("#J_LoggedOut"),
                navLoggedIn = All("#J_LoggedIn"),
                navLoggedInName = All("#J_LoggedIn_Name");

        if (userPopupNode.length > 0) {
            userPopup = new UI.Popup(userPopupNode, {
                trigger: userPopupShow,
                showTriggerType: "mouseenter",
                hideTriggerType: "mouseleave",
                prefixCls: "fgt-",
                alignNode: userPopupShow
            });
        }

        J.ajax({
            url: "/account/getuserstatus",
            type: "GET",
            cache: false,
            success: function (data, textStatus, jqXHR) {
                if (data.Result === resultCode.SUCCESS) {
                    navLoggedInName.text(data.Content.Name);
                    navLoggedOut.hide();
                    navLoggedIn.show();
                }
                else {
                    navLoggedIn.hide();
                    navLoggedOut.show();
                }
            }
        });



//        var isSupport = "placeholder" in document.createElement("input");
//        if (isSupport) {
//            return;
//        }

//        S.use("util/placeholder", function (S, Placeholder) {
//            J(":text,textarea").each(function (index) {
//                Placeholder(this);
//            });
//        });
    });
});

